package tech.aistar.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import tech.aistar.entity.Post;
import tech.aistar.entity.UserInfo;
import tech.aistar.service.ISearchService;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/search")
public class SearchController {
    @Autowired
    private ISearchService searchService;

    @GetMapping("/index")
    public String test01(String any, Model model){
        List<Post> selpost = new ArrayList<>();
        List<Post> sel01 = searchService.selPost(any);
        List<Post> sel02 = searchService.selPosts(any);
        selpost.addAll(sel01);
        selpost.addAll(sel02);
        model.addAttribute("selpost",selpost);
        List<UserInfo> seluser = searchService.selUser(any);
        model.addAttribute("seluser",seluser);
        UserInfo quser = searchService.selQUser(any);
        model.addAttribute("quser",quser);
        return "/person/search";
    }
}
